package com.cx.robot.controller;

import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ：刘剑鸿
 * @date ：Created in 2022/9/19 9:41
 * @description：12306购票
 * @modified By：
 * @version: $
 */
@RestController
public class RailWayController {
    @GetMapping("/ticket")
    public String goTicket() throws InterruptedException {
        System.setProperty("webdriver.chrome.driver","C:\\JAVA\\Environment\\chromedriver.exe");

        ChromeDriver chromeDriver = new ChromeDriver();
        chromeDriver.get("https://www.12306.cn/index/");
        Thread.sleep(3000);
        chromeDriver.findElement(By.linkText("登录")).click();
        Thread.sleep(2000);
        chromeDriver.findElement(By.className("login-hd-account")).click();
        Thread.sleep(5000);
        chromeDriver.findElement(By.linkText("首页")).click();
        chromeDriver.findElement(By.name("from_station")).sendKeys("GZQ");
        Thread.sleep(1000);
        chromeDriver.findElement(By.name("to_station")).sendKeys("NWQ");

        return null;
    }

}
